import { APIBOSSPREFIX, APIPCPREFIX } from '@/common';
import { request } from '../request';

// 获取Boss资源目录
export const searchResourceCatalogList = (params: any) =>
  request({
    url: `${
      process.env.processEnvDetail.REACT_APP_PLATFORM === 'boss' ? APIBOSSPREFIX : APIPCPREFIX
    }resourceCatalog/list`,
    params,
  });

// 新建资源目录
export const createResourceCatalog = (data: any) =>
  request({
    url: `${
      process.env.processEnvDetail.REACT_APP_PLATFORM === 'boss' ? APIBOSSPREFIX : APIPCPREFIX
    }resourceCatalog/create`,
    data,
  });

// 编辑资源目录
export const editResourceCatalog = (params: any) =>
  request({
    url: `${
      process.env.processEnvDetail.REACT_APP_PLATFORM === 'boss' ? APIBOSSPREFIX : APIPCPREFIX
    }resourceCatalog/rename`,
    params,
    method: 'get',
  });

// 删除资源目录
export const deleteResourceCatalog = (params: any) =>
  request({
    url: `${
      process.env.processEnvDetail.REACT_APP_PLATFORM === 'boss' ? APIBOSSPREFIX : APIPCPREFIX
    }resourceCatalog/delete`,
    params,
    method: 'get',
  });

// 删除课件
export const deleteCourseWare = (params: any) =>
  request({
    url:
      process.env.processEnvDetail.REACT_APP_PLATFORM === 'boss'
        ? `${APIBOSSPREFIX}courseware/delete`
        : '/safe/api/entCourseware/remove',
    params,
  });
// 政协/企业删除考题
export const deleteQuestion = (params: any) =>
  request({
    url: '/safe/api/safeQuestion/remove',
    params,
  });
// 删除试卷
export const deletePaper = (params: any) =>
  request({
    url: 'safe/api/safePaper/remove',
    params,
  });
// 新增课件、试卷(不包含政协/企业的新增试卷)
export const createCourseWare = (data: any) =>
  request({
    url: '/safe/api/entCourseware/add',
    data,
  });
// 政协/企业 自建资料库新试卷
export const createPaper = (data: any) =>
  request({
    url: '/safe/api/safePaper/addPaper',
    data,
  });
// 政协/企业 自建资料库试卷的详情
export const getPaperDetailById = (params: { coursewareId: string }) =>
  request<{
    coursewareId: string;
    name: string;
    /**
     * @desc 封面图
     */
    picUrl?: string;
    pictextContent: string;
    coursewareType: 'pdf' | 'txt' | 'vido';
    createTime: string;
    newCreateTime: string;
    updateTime: string;
    vedioId?: string;
  }>({
    url: '/safe/api/safePaper/review/' + params.coursewareId,
    params,
  });
// 编辑课件，试卷
export const updateCourseWare = (data: any) =>
  request({
    url: '/safe/api/entCourseware/add',
    data,
  });
// 获取课件详情
export const getCourseWareById = (params: { coursewareId: string }) =>
  request<{
    coursewareId: string;
    name: string;
    /**
     * @desc 封面图
     */
    picUrl?: string;
    pictextContent: string;
    coursewareType: 'pdf' | 'txt' | 'vido';
    createTime: string;
    newCreateTime: string;
    updateTime: string;
    vedioId?: string;
  }>({
    url: '/safe/api/entCourseware/detail/' + params.coursewareId,
    params,
  });

// 新增考题
export const createExamination = (data: any) =>
  request({
    // url: `${APIBOSSPREFIX}question/create`,
    url:
      process.env.processEnvDetail.REACT_APP_PLATFORM === 'boss'
        ? '/safe/api/platform/question/create'
        : '/safe/api/safeQuestion/addList',
    data,
  });

// 编辑考题
export const updateExamination = (data: any) => request({ url: `${APIBOSSPREFIX}question/update`, data });

// 考题详情
export const getExaminationById = (params: any) =>
  request({
    url:
      process.env.processEnvDetail.REACT_APP_PLATFORM === 'boss'
        ? `${APIBOSSPREFIX}question/queryById`
        : '/safe/api/safeQuestion/detail/' + params.questionId,
    params,
  });
